/*
 * @lc app=leetcode.cn id=844 lang=javascript
 *
 * [844] 比较含退格的字符串
 */

// @lc code=start
/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
function getStr (str) {
    const stack = [];
    for(let k in str) {
        if (str[k] === '#') {
            stack.pop();
        } else {
            stack.push(str[k]);
        }
    }
    return stack.join('');
}
var backspaceCompare = function(s, t) {
   const s1 = getStr(s);
   const t1 = getStr(t);
   return s1 === t1;
};
// @lc code=end

